package cn.tedu.elasticsearch.pojo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.io.Serializable;

@Data
@Accessors(chain = true) //开启链式set赋值的功能
@AllArgsConstructor
@NoArgsConstructor
@Document(indexName = "items")
public class Item implements Serializable {

    @Id //标记为ES的主键
    private Long id;
    @Field(type = FieldType.Text,
            analyzer = "ik_max_word",
            searchAnalyzer = "ik_max_word")
    private String title; //商品的名称
    @Field(type = FieldType.Keyword) //不需要进行切分
    private String brand;//商品的品牌
    @Field(type = FieldType.Keyword) //不需要进行切分
    private String category;//商品的分类
    @Field(type = FieldType.Double)
    private Double price; //价格
    @Field(type = FieldType.Keyword,index = false) //不创建索引
    private String imgPath; //图片地址
}